import {ref, computed} from 'vue'
import {defineStore} from 'pinia'

export const useCounterStore = defineStore('balance', () => {
        const userInfo = ref([
            {
                email: "",
                password: "",
            }
        ])
        const addressList = ref([
            {
                id: '1',
                name: '张三',
                tel: '13000000000',
                address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
            },
            {
                id: '2',
                name: '李四',
                tel: '1310000000',
                address: '浙江省杭州市拱墅区莫干山路 50 号',
            },
        ])
        const balance = ref(1000000)
        const goodList = ref([])
        const orderList = ref([])
        const starStore = ref([])
        const foodList = ref([
            {
                id: 1,
                src: "/img/美食/快餐店1.png",
                name: "快餐一号",
                type: "美食",
                value: 4.7,
                sale: 250,
                price1: 15,
                price2: 2,
                distance: 2.8,
                star: 1,
                idx: 0,
                order: [
                    {
                        id: 1,
                        name: '招牌炒饭',
                        src: 'img/发现/快餐店1/招牌炒饭.png',
                        price: 88.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 2,
                        name: '家乡小炒肉',
                        src: 'img/发现/快餐店1/家乡小炒肉.png',
                        price: 40.1,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 3,
                        name: '清蒸鲈鱼',
                        src: 'img/发现/快餐店1/清蒸鲈鱼.png',
                        price: 48.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                ]
            },
            {
                id: 2,
                src: "/img/美食/家常菜馆1.png",
                name: "家常味道",
                type: "美食",
                value: 4.9,
                sale: 198,
                price1: 18,
                price2: 3,
                distance: 3.2,
                star: 0,
                idx: 0,
                order: [
                    {
                        id: 4,
                        name: '麻辣香锅',
                        src: 'img/发现/家常菜馆1/麻辣香锅.png',
                        price: 50.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 5,
                        name: '宫保鸡丁',
                        src: 'img/发现/家常菜馆1/宫保鸡丁.png',
                        price: 58.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 6,
                        name: '鱼香茄子',
                        src: 'img/发现/家常菜馆1/鱼香茄子.png',
                        price: 22.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                ]
            },
            {
                id: 3,
                src: "/img/火锅/火锅餐厅.png",
                name: "火锅英雄",
                type: "火锅",
                value: 4.5,
                sale: 300,
                price1: 25,
                price2: 5,
                distance: 4.1,
                star: 0,
                idx: 1,
                order: [
                    {
                        id: 7,
                        name: '至尊牛肉火锅',
                        src: 'img/发现/火锅餐厅1/至尊牛肉火锅.png',
                        price: 68.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 8,
                        name: '鸳鸯火锅',
                        src: 'img/发现/火锅餐厅1/鸳鸯火锅.png',
                        price: 52.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 9,
                        name: '蔬菜拼盘',
                        src: 'img/发现/火锅餐厅1/蔬菜拼盘.png',
                        price: 33.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    }
                ]
            },
            {
                id: 4,
                src: "/img/生鲜/生鲜超市.png",
                name: "生鲜精选",
                type: "生鲜",
                value: 4.6,
                sale: 120,
                price1: 10,
                price2: 2,
                distance: 1.5,
                star: 1,
                idx: 2,
                order: [
                    {
                        id: 10,
                        name: '新鲜三文鱼',
                        src: 'img/发现/生鲜超市1/新鲜三文鱼.png',
                        price: 48.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 11,
                        name: '澳洲牛排',
                        src: 'img/发现/生鲜超市1/澳洲牛排.png',
                        price: 45.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 12,
                        name: '有机蔬菜盒',
                        src: 'img/发现/生鲜超市1/有机蔬菜盒.png',
                        price: 78.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    }
                ]
            },
            {
                id: 5,
                src: "/img/果蔬/果蔬市场.png",
                name: "果蔬园",
                type: "果蔬",
                value: 4.8,
                sale: 95,
                price1: 8,
                price2: 1,
                distance: 2.5,
                star: 0,
                idx: 3,
                order: [
                    {
                        id: 13,
                        name: '有机苹果',
                        src: 'img/发现/果蔬市场1/有机苹果.png',
                        price: 20.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 14,
                        name: '进口香蕉',
                        src: 'img/发现/果蔬市场1/进口香蕉.png',
                        price: 8.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 15,
                        name: '新鲜橙子',
                        src: 'img/发现/果蔬市场1/新鲜橙子.png',
                        price: 18.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    }
                ]
            },
            {
                id: 6,
                src: "/img/烧烤/烧烤摊1.png",
                name: "烧烤部落",
                type: "烧烤",
                value: 4.7,
                sale: 180,
                price1: 28,
                price2: 6,
                distance: 3.0,
                star: 0,
                idx: 4,
                order: [
                    {
                        id: 16,
                        name: '羊肉串',
                        src: 'img/发现/烧烤摊1/羊肉串.png',
                        price: 28.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 17,
                        name: '烤鸡翅',
                        src: 'img/发现/烧烤摊1/烤鸡翅.png',
                        price: 28.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 18,
                        name: '烤鱿鱼',
                        src: 'img/发现/烧烤摊1/烤鱿鱼.png',
                        price: 95.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    }
                ]
            },
            {
                id: 7,
                src: "/img/下午茶/甜品店1.png",
                name: "甜蜜午后",
                type: "下午茶",
                value: 4.9,
                sale: 75,
                price1: 12,
                price2: 2,
                distance: 1.8,
                star: 0,
                idx: 5,
                order: [
                    {
                        id: 18,
                        name: '芒果慕斯',
                        src: 'img/发现/甜品店1/芒果慕斯.png',
                        price: 35.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 19,
                        name: '提拉米苏',
                        src: 'img/发现/甜品店1/提拉米苏.png',
                        price: 28.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 20,
                        name: '抹茶蛋糕',
                        src: 'img/发现/甜品店1/抹茶蛋糕.png',
                        price: 30.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    }
                ]
            },
            {
                id: 8,
                src: "/img/披萨/披萨屋1.png",
                name: "披萨王国",
                type: "披萨",
                value: 4.6,
                sale: 200,
                price1: 22,
                price2: 4,
                distance: 2.9,
                star: 0,
                idx: 6,
                order: [
                    {
                        id: 21,
                        name: '海鲜至尊披萨',
                        src: 'img/发现/披萨屋1/海鲜至尊披萨.png',
                        price: 55.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 22,
                        name: '意大利烤肉披萨',
                        src: 'img/发现/披萨屋1/意大利烤肉披萨.png',
                        price: 120.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 23,
                        name: '素食者之选',
                        src: 'img/发现/披萨屋1/素食者之选.png',
                        price: 114.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    }
                ]
            },
            {
                id: 9,
                src: "/img/面包/面包房1.png",
                name: "面包新语",
                type: "面包",
                value: 4.5,
                sale: 150,
                price1: 10,
                price2: 2,
                distance: 2.1,
                star: 0,
                idx: 7,
                order: [
                    {
                        id: 24,
                        name: '全麦吐司',
                        src: 'img/发现/面包房1/全麦吐司.png',
                        price: 33.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 25,
                        name: '蓝莓芝士面包',
                        src: 'img/发现/面包房1/蓝莓芝士面包.png',
                        price: 19.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 26,
                        name: '法式长棍',
                        src: 'img/发现/面包房1/法式长棍.png',
                        price: 5.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    }
                ]
            },
            {
                id: 10,
                src: "/img/炸鸡/炸鸡店1.png",
                name: "炸鸡传奇",
                type: "炸鸡",
                value: 4.8,
                sale: 100,
                price1: 15,
                price2: 3,
                distance: 3.5,
                star: 0,
                idx: 8,
                order: [
                    {
                        id: 27,
                        name: '黄金炸鸡翅',
                        src: 'img/发现/炸鸡店1/黄金炸鸡翅.png',
                        price: 27.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 28,
                        name: '脆皮炸鸡',
                        src: 'img/发现/炸鸡店1/脆皮炸鸡.png',
                        price: 88.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 29,
                        name: '炸鸡柳',
                        src: 'img/发现/炸鸡店1/炸鸡柳.png',
                        price: 66.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    }
                ]
            },
            {
                id: 11,
                src: "/img/鲜花/花店1.png",
                name: "花香满屋",
                type: "鲜花",
                value: 4.7,
                sale: 50,
                price1: 50,
                price2: 10,
                distance: 4.0,
                star: 0,
                idx: 9,
                order: [
                    {
                        id: 30,
                        name: '红玫瑰',
                        src: 'img/发现/花店1/红玫瑰.png',
                        price: 66.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 31,
                        name: '百合花束',
                        src: 'img/发现/花店1/百合花束.png',
                        price: 28.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    },
                    {
                        id: 32,
                        name: '康乃馨',
                        src: 'img/发现/花店1/康乃馨.png',
                        price: 18.0,
                        specs: '微辣',
                        quantity: 0,
                        num: 0,
                        status: "待配送",
                        star: "收藏",
                    }
                ]
            }
        ])

        function increment(price) {
            balance.value -= price
        }

        function del(id) {
            goodList.value = goodList.value.filter(item => item.id !== id)
        }

        function add(item) {
            goodList.value.push(item)
        }

        return {
            balance, goodList, orderList, starStore, foodList, userInfo, addressList,
            del, add, increment
        }
    }, {
        persist: true
    }
)
export default useCounterStore